package thread.timethreadpool;

import java.util.Random;

/**
 * @auther zhouliangliang
 * @date 2022/7/25 14:10
 * @description TimerThreadPool 的测试
 */
public class TimerThreadPoolExecutorTest {
    private Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                int value = new Random().nextInt();
                value = Math.abs(value % 100);
                Thread.sleep(value);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    private void test() {
        for(int i=0; i<100; i++) {
            ThreadPools.getTimerThreadPool().execute(thread);
        }
        ThreadPools.getTimerThreadPool().shutdown();
    }

    public static void main(String[] args) {
        new TimerThreadPoolExecutorTest().test();
    }
}
